import request from '@/utils/request'

// 查询生产工单列表
export function listWorkorder(query) {
  return request({
    url: '/mes/pro/workorder/list',
    method: 'get',
    params: query
  })
}

// 查询排除已完成的生产工单列表
export function listDropDownBox(query) {
  return request({
    url: '/mes/pro/workorder/dropDownBox',
    method: 'get',
    params: query
  })
}

// 查询生产工单下的任务列表
export function listTask(query) {
  return request({
    url: '/mes/pro/workorder/listTask/' + query.workorderId,
    method: 'get',
    // params: query
  })
}
// 查询生产工单详细
export function getWorkorder(workorderId) {
  return request({
    url: '/mes/pro/workorder/' + workorderId,
    method: 'get'
  })
}

//查询生产工单，并携带每个生产工单下生产任务的情况
export function listWithTaskJson(query) {
  return request({
    url: '/mes/pro/workorder/listWithTaskJson',
    method: 'get',
    params: query
  })
}

// 新增生产工单
export function addWorkorder(data) {
  return request({
    url: '/mes/pro/workorder',
    method: 'post',
    data: data
  })
}

// 修改生产工单
export function updateWorkorder(data) {
  return request({
    url: '/mes/pro/workorder',
    method: 'put',
    data: data
  })
}

// 删除生产工单
export function delWorkorder(workorderId) {
  return request({
    url: '/mes/pro/workorder/' + workorderId,
    method: 'delete'
  })
}

// 查询物料依赖列表
export function listItems(query) {
  return request({
    url: '/mes/pro/workorder/listItems',
    method: 'get',
    params: query
  })
}

export function dofinish(workorderId){
  return request({
    url: '/mes/pro/workorder/'+workorderId,
    method: 'put'
  })
}

/** 查询工单质检记录 */ 
export function getCheckWorkOrder(workorderId) {
  return request({
    url: '/mes/pro/workorder/check/' + workorderId,
    method: 'get'
  })
}

/** 查询工单领料记录 */ 
export function getIssueWorkOrder(workorderId) {
  return request({
    url: '/mes/pro/workorder/issue/' + workorderId,
    method: 'get'
  })
}

/** 查询物料需求清单 */ 
export function getListItemsOrder() {
  return request({
    url: '/mes/pro/workorder/listItems',
    method: 'get'
  })
}

/** 查询工单入库记录 */ 
export function getRepectWorkOrder(workorderId) {
  return request({
    url: '/mes/pro/workorder/repect/' + workorderId,
    method: 'get'
  })
}

/** 查询工单执行进度 */ 
export function getResumeWorkOrder(workorderId) {
  return request({
    url: '/mes/pro/workorder/resume/' + workorderId,
    method: 'get'
  })
}

/** 查询生产/外协退料记录 */ 
export function getRtIssueWorkOrder(workorderId) {
  return request({
    url: '/mes/pro/workorder/rtIssue/' + workorderId,
    method: 'get'
  })
}
// 生产工单下发
export function dispatchWorkorder(data) {
  return request({
    url: '/mes/pro/workorder/dispatch',
    method: 'put',
    data: data
  })
}

// 生产工单下的报工记录
export function workReportRecordList(workorderId) {
  return request({
    url: '/mes/pro/workorder/feedback/'+ workorderId,
    method: 'get',
  })
}